<script lang="ts" setup>
import {useAppStore} from '@/stores/app'
import {storeToRefs} from 'pinia'

const store = useAppStore()
const {count} = storeToRefs(store)

import p2 from '@/components/p2.vue'
</script>
<template>
  <p>count:{{ count }}</p>

  <!-- 不建议使用pinia直接改变状态的值 -->
  <button @click="store.count+=3">change(3)</button>
  <button @click="count+=-3">change(-3)</button>

  <!-- 推荐 -->
  <button @click="store.change(3)">add+3</button>
  <button @click="store.change(-5)">add-5</button>

  <hr>
  <p2/>
</template>
